<template>
	<div class="heightMax publicbox" v-loading='tableLoading'>
		<div class="header">
			<div class="listName">
				<i></i><span class="font14">组织管理信息</span>
			</div>
			<div v-if="btnLocation">
				<el-button type="primary" size="mini" @click="enture('form',1)" v-loading='submitBtn' v-if="!detailShow">保存</el-button>
				<el-button size="mini" @click='backRouter(1)'>返回</el-button>
			</div>
		</div>
		<div class="content">
			<vueScroll>
				<el-form ref="form" :model="form" :rules="rules" label-width="100px" size='mini'>
					<el-row :gutter="20">
						<el-col :span="7" :offset='1'>
							<el-form-item label="单位类型:" prop="companyType">
								<el-select @change="companyTypeChange" v-model="form.companyType" placeholder="请选择单位类型" size="mini" clearable
								 :disabled='detailShow'>
									<el-option v-for="(item,index) in companyTypeArr" :label="item.label" :value="item.value" :key='index'></el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="7" v-if="form.companyType || form.companyType === 0">
							<el-form-item label="单位名称:" prop="companyName">
								<el-input type="text" v-model="form.companyName" placeholder="请输入单位名称" size="mini" clearable :disabled='detailShow'></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7" v-if="form.companyType  ">
							<el-form-item label="单位电话:">
								<el-input type="text" v-model="form.comTelephone" placeholder="请输入单位电话" size="mini" clearable :disabled='detailShow'></el-input>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="20" v-if="form.companyType ">
						<el-col :span="7" :offset='1'>
							<el-form-item label="24小时电话:">
								<el-input type="text" v-model="form.allDayTele" placeholder="请输入24小时小时电话" size="mini" clearable :disabled='detailShow'></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7">
							<el-form-item label="主要负责人:">
								<el-input type="text" v-model="form.principal" placeholder="请输入主要负责人" size="mini" clearable :disabled='detailShow'></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7">
							<el-form-item label="负责人电话:">
								<el-input type="text" v-model="form.principalTele" placeholder="请输入主要负责人电话" size="mini" clearable :disabled='detailShow'></el-input>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="20">
						<el-col :span="7" :offset='1' v-if="form.companyType === 20 || form.companyType == 10">
							<el-form-item label="单位地址:">
								<el-input type="text" v-model="form.unitSite" placeholder="请输入单位地址" size="mini" clearable :disabled='detailShow'></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7">
							<el-form-item label="web标题设置:" v-if="form.companyType == 10">
								<el-input type="text" v-model="form.title" placeholder="请输入标题信息" maxlength="128" size="mini" clearable
								 :disabled='detailShow'></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7" :offset='isOffSet' v-if="form.companyType && form.companyType != 10">
							<el-form-item label="法人:">
								<el-input type="text" v-model="form.legalPerson " placeholder="请输入法人" size="mini" clearable :disabled='detailShow'></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7" v-if="form.companyType && form.companyType != 10">
							<el-form-item label="法人电话:">
								<el-input type="text" v-model="form.legalPersonTele" placeholder="请输入法人电话" size="mini" clearable :disabled='detailShow'></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7" v-if="form.companyType == 30">
							<el-form-item label="社会信用码:">
								<el-input type="text" v-model="form.societyCode" placeholder="请输入社会信用码" size="mini" clearable :disabled='detailShow'></el-input>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="20" v-if="form.companyType == 30">
						<el-col :span="7" :offset='1' v-if=" role == 0">
							<el-form-item label="系统对接账号:">
								<el-input type="text" v-model="form.sysCount" placeholder="请输入系统对接账号" size="mini" clearable :disabled='detailShow'></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7">
							<el-form-item label="系统对接令牌:" v-if=" role == 0">
								<el-input type="text" v-model="form.sysCard" placeholder="请输入系统对接令牌" size="mini" clearable :disabled='detailShow'></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7" :offset='webSet'>
							<el-form-item label="web标题设置:">
								<el-input type="text" v-model="form.title" placeholder="请输入标题信息" maxlength="128" size="mini" clearable
								 :disabled='detailShow'></el-input>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="20" v-if="form.companyType == 20">
						<el-col :span="7" :offset='newOffSet'>
							<el-form-item label="社会信用码:">
								<el-input type="text" v-model="form.societyCode" placeholder="请输入社会信用码" size="mini" clearable :disabled='detailShow'></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7">
							<el-form-item label="web标题设置:">
								<el-input type="text" v-model="form.title" placeholder="请输入标题信息" maxlength="128" size="mini" clearable
								 :disabled='detailShow'></el-input>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="20">
						<el-col :span="7" :offset='1' v-if="form.companyType && form.companyType == 30">
							<el-form-item label="营业执照:" prop="pactAffix1">
								<el-upload :on-preview="upLoadPreview" action="" accept=".jpg,.jpeg,.png" :file-list="fileList1" :on-change="upLoadChange1"
								 :on-remove="upLoadRemove1" :auto-upload="false" list-type="picture" name="upfile" :disabled='detailShow'>
									<el-button size="mini" type="primary" :disabled='detailShow'>点击上传</el-button>
									<div slot="tip" class="upLoadText">只能上传JPG/PNG/JPEG图片,大小不超过800kb/最多上传1张</div>
								</el-upload>
							</el-form-item>
						</el-col>
						<el-col :span="7" :offset='isOffSet' v-if="form.companyType && form.companyType == 30">
							<el-form-item label="特种改造许可证:" prop="pactAffix2" label-width='130px'>
								<el-upload :on-preview="upLoadPreview" action="" accept=".jpg,.jpeg,.png" :file-list="fileList2" :on-change="upLoadChange2"
								 :on-remove="upLoadRemove2" :auto-upload="false" list-type="picture" name="upfile" :disabled='detailShow'>
									<el-button size="mini" type="primary" :disabled='detailShow'>点击上传</el-button>
									<div slot="tip" class="upLoadText">只能上传JPG/PNG/JPEG图片,大小不超过800kb/最多上传1张</div>
								</el-upload>
							</el-form-item>
						</el-col>
					</el-row>
					<div v-if="form.companyType && form.companyType == 30">
						<div class="header">
							<div class="listName">
								<i></i><span class="font14">注册地址</span>
							</div>
						</div>
						<el-row :gutter="20">
							<el-col :span="7" :offset='1'>
								<el-form-item label="省份:">
									<el-select size="mini" @change="changeArr(1)" v-model="form.signProvince" placeholder="请选择省份" clearable
									 :disabled='detailShow'>
										<el-option v-for="item in signProvinceArr" :key="item.address_code" :label="item.name" :value="item.address_code">
										</el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="7">
								<el-form-item label="城市:">
									<el-select size="mini" @change="changeArr(2)" v-model="form.signCity" placeholder="请选择城市" :disabled="signCityDis || detailShow"
									 clearable>
										<el-option v-for="item in signCityArr" :key="item.address_code" :label="item.name" :value="item.address_code">
										</el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="7">
								<el-form-item label="区/县:">
									<el-select size="mini" @change="changeArr(3)" v-model="form.signArea" placeholder="请选择区/县" :disabled="signAreaDis || detailShow"
									 clearable>
										<el-option v-for="item in signAreaArr" :key="item.address_code" :label="item.name" :value="item.address_code">
										</el-option>
									</el-select>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="20">
							<el-col :span="7" :offset='1'>
								<el-form-item label="街道:">
									<el-select size="mini" v-model="form.signStreet" placeholder="请选择街道" :disabled="signStreetDis || detailShow"
									 clearable>
										<el-option v-for="item in signStreetArr" :key="item.address_code" :label="item.name" :value="item.address_code">
										</el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="7">
								<el-form-item label="详细地址:">
									<el-input type="text" v-model="form.signDetailSite" placeholder="请输入详细地址" size="mini" clearable :disabled='detailShow'></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						<div class="header">
							<div class="listName">
								<i></i><span class="font14">维保网点地址</span>
							</div>
						</div>
						<el-row :gutter="20">
							<el-col :span="7" :offset='1'>
								<el-form-item label="省份:">
									<el-select size="mini" @change="changeArr1(1)" v-model="form.networkProvince" placeholder="请选择省份" clearable
									 :disabled='detailShow'>
										<el-option v-for="item in networkProvinceArr" :key="item.address_code" :label="item.name" :value="item.address_code">
										</el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="7">
								<el-form-item label="城市:">
									<el-select size="mini" @change="changeArr1(2)" v-model="form.networkCity" placeholder="请选择城市" :disabled="networkCityDis || detailShow"
									 clearable>
										<el-option v-for="item in networkCityArr" :key="item.address_code" :label="item.name" :value="item.address_code">
										</el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="7">
								<el-form-item label="区/县:">
									<el-select size="mini" @change="changeArr1(3)" v-model="form.networkArea" placeholder="请选择区/县" :disabled="networkAreaDis || detailShow"
									 clearable>
										<el-option v-for="item in networkAreaArr" :key="item.address_code" :label="item.name" :value="item.address_code">
										</el-option>
									</el-select>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="20">
							<el-col :span="7" :offset='1'>
								<el-form-item label="街道:">
									<el-select size="mini" v-model="form.networkStreet" placeholder="请选择街道" :disabled="networkStreetDis || detailShow"
									 clearable>
										<el-option v-for="item in networkStreetArr" :key="item.address_code" :label="item.name" :value="item.address_code">
										</el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="7">
								<el-form-item label="详细地址:">
									<el-input type="text" v-model="form.netDetailSite" placeholder="请输入详细地址" size="mini" clearable :disabled='detailShow'></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						<div v-if="role == 0 && nowStatus == 2">
							<div class="header">
								<div class="listName">
									<i></i><span class="font14">匹配结果</span>
								</div>
							</div>
							<el-row :gutter="20">
								<el-col :span="7" :offset='1'>
									<el-form-item label="更新状态:">
										<el-input size="mini" v-model="updataType" autocomplete="off" clearable disabled></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="7">
									<el-form-item label="最后更新时间">
										<el-date-picker size="mini" v-model="lastUpdataTime" type="date" placeholder="请选择最后更新时间" format="yyyy-MM-dd HH:mm:ss"
										 value-format="yyyy-MM-dd HH:mm:ss" clearable disabled>
										</el-date-picker>
									</el-form-item>
								</el-col>
							</el-row>
							<div class="header">
								<div class="listName">
									<i></i><span class="font14">备案原始数据</span>
								</div>
							</div>
							<el-row>
								<el-col :span="16" :offset="1">
									<div class="copy" id="content">
										{{recordCon}}
									</div>
									<el-button type="primary" style="margin-left: 170px;margin-top:15px" @click="copy">复制所有请求信息</el-button>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="16" :offset="1">
									<div class="copy" id="content1" style="white-space: inherit;">
										{{recordCon1}}
									</div>
									<el-button type="primary" style="margin-left: 170px;margin-top:15px" @click="copy1">复制所有返回信息</el-button>
								</el-col>
							</el-row>
						</div>
					</div>
				</el-form>
			</vueScroll>
		</div>
		<div v-if="!btnLocation">
			<div class="fr">
				<el-button type="primary" size="mini" @click="enture('form',2)" v-loading='submitBtn' v-if="!detailShow">保存</el-button>
				<el-button size="mini" @click='backRouter(2)'>取消</el-button>
			</div>
		</div>
		<el-dialog custom-class="imgDialogShow" :visible.sync="imgDialogShow" :append-to-body='true' :before-close='closeImg'>
			<img :src="dialogImgUrl" alt="">
		</el-dialog>
	</div>
	</div>
</template>

<script>
	import {
		loadFn,
		axiosPost,
		axiosGet,
		axiosDelete,
		axiosPut,
		AllLoading,
		axiosChange
	} from "@/common.js";
	import {
		companyName,
		companyType
	} from "./rule.js"
	export default {
		props: {
			nowStatus: {
				type: Number,
				default () {
					return 0 //0是添加  1是编辑 2是详情
				}
			},
			btnLocation: {
				type: Boolean,
				default () {
					return true
				}
			}
		},
		mounted() {
			this.changeCompanyTypeArr()
			this.getProvince()
			if (this.nowStatus) {
				this.getComplieList()
				this.companyTypeArr.push({
					label: '维保单位',
					value: 30
				})
			}
		},
		data() {
			let valiPic1 = (rule, value, callback) => {
				if (this.fileList1.length === 0) {
					callback(new Error('请上传营业执照'));
				} else {
					callback();
				}
			}
			let valiPic2 = (rule, value, callback) => {
				if (this.fileList2.length === 0) {
					callback(new Error('请上传特种许可改造证'));
				} else {
					callback();
				}
			}
			return {
				recordCon: '',
				recordCon1: '',
				updataType: '',
				lastUpdataTime: '',
				fileList1: [],
				fileList2: [],
				signProvinceArr: [],
				networkProvinceArr: [],
				form: {
					companyName: '',
					companyType: '',
					comTelephone: '',
					allDayTele: '',
					principal: '',
					principalTele: '',
					unitSite: '',
					societyCode: '',
					legalPerson: '',
					legalPersonTele: '',
					signProvince: '',
					signCity: '',
					signArea: '',
					signStreet: '',
					networkProvince: '',
					networkCity: '',
					networkArea: '',
					networkStreet: '',
					netDetailSite: '',
					signDetailSite: '',
					sysCount: '',
					sysCard: '',
					title: ''
				},
				companyTypeArr: [],
				rules: {
					companyName,
					companyType,
					pactAffix1: [{
						required: true,
						trigger: 'blur',
						validator: valiPic1
					}],
					pactAffix2: [{
						required: true,
						trigger: 'blur',
						validator: valiPic2
					}],
				},
				tableLoading: false,
				submitBtn: false,
				imgDialogShow: false,
				dialogImgUrl: '',
				networkCityDis: true,
				networkAreaDis: true,
				networkStreetDis: true,
				signCityDis: true,
				signAreaDis: true,
				signStreetDis: true
			}
		},
		computed: {
			detailShow() {
				if (this.nowStatus == 2) {
					return true
				} else {
					return false
				}
			},
			webSet() {
				if (this.role == 0) {
					return 0
				} else {
					return 1
				}
			},
			//注册 城市
			signCityArr() {
				if (this.signProvinceArr.length != 0 && this.form.signProvince) {
					return this.signProvinceArr.find((item) => {
						return item.address_code === this.form.signProvince
					}).children;
				} else {
					return []
				}
			},
			//注册 区/县
			signAreaArr() {
				if (this.signCityArr.length != 0 && this.form.signCity) {
					return this.signCityArr.find((item) => {
						return item.address_code == this.form.signCity
					}).children
				} else {
					return []
				}
			},
			//注册 街道
			signStreetArr() {
				if (this.signAreaArr.length != 0 && this.form.signArea) {
					return this.signAreaArr.find((item) => {
						return item.address_code == this.form.signArea
					}).children
				} else {
					return []
				}
			},
			//网点 城市
			networkCityArr() {
				if (this.networkProvinceArr.length != 0 && this.form.networkProvince) {
					return this.networkProvinceArr.find((item) => {
						return item.address_code === this.form.networkProvince
					}).children;
				} else {
					return []
				}
			},
			//网点 区/县
			networkAreaArr() {
				if (this.networkCityArr.length != 0 && this.form.networkCity) {
					return this.networkCityArr.find((item) => {
						return item.address_code == this.form.networkCity
					}).children
				} else {
					return []
				}
			},
			//网点地址 街道
			networkStreetArr() {
				if (this.networkAreaArr.length != 0 && this.form.networkArea) {
					return this.networkAreaArr.find((item) => {
						return item.address_code == this.form.networkArea
					}).children
				} else {
					return []
				}
			},
			isOffSet() {
				if (this.form.companyType == 30) {
					return 1
				} else {
					return 0
				}
			},
			newOffSet() {
				if (this.form.companyType == 20) {
					return 1
				} else {
					return 0
				}
			},
			organizationId() {
				if (localStorage.frameworkId) {
					return JSON.parse(localStorage.frameworkId).id
				} else {
					return ''
				}
			},
			role() {
				if (localStorage.role) {
					return JSON.parse(localStorage.role).id
				} else {
					return ''
				}
			},
		},
		methods: {
			copy() {
				/* 创建range对象   */
				const range = document.createRange();
				range.selectNode(document.getElementById('content'));
				/* 窗口的selection对象，表示用户选择的文本 */
				const selection = window.getSelection();
				if (selection.rangeCount > 0) selection.removeAllRanges(); // 将已经包含的已选择的对象清除掉
				selection.addRange(range); // 将要复制的区域的range对象添加到selection对象中
				document.execCommand('copy'); // 执行copy命令，copy用户选择的文本
			},
			copy1() {
				/* 创建range对象   */
				const range = document.createRange();
				range.selectNode(document.getElementById('content1'));
				/* 窗口的selection对象，表示用户选择的文本 */
				const selection = window.getSelection();
				if (selection.rangeCount > 0) selection.removeAllRanges(); // 将已经包含的已选择的对象清除掉
				selection.addRange(range); // 将要复制的区域的range对象添加到selection对象中
				document.execCommand('copy'); // 执行copy命令，copy用户选择的文本
			},
			companyTypeChange(res) {
				this.form.companyType = ''
				this.form.companyName = ''
				this.form.comTelephone = ''
				this.form.allDayTele = ''
				this.form.principal = ''
				this.form.principalTele = ''
				this.form.unitSite = ''
				this.form.societyCode = ''
				this.form.legalPerson = ''
				this.form.legalPersonTele = ''
				this.form.signProvince = ''
				this.form.signCity = ''
				this.form.signArea = ''
				this.form.signStreet = ''
				this.form.networkProvince = ''
				this.form.networkCity = ''
				this.form.networkArea = ''
				this.form.networkStreet = ''
				this.form.netDetailSite = ''
				this.form.signDetailSite = ''
				this.form.sysCount = ''
				this.form.title = ''
				this.form.sysCard = ''
				this.fileList1 = []
				this.fileList2 = []
				this.form.companyType = res
			},
			//三级变化
			changeArr(value) {
				if (value == 1) {
					this.form.signCity = ''
					this.form.signArea = ''
					this.form.signStreet = ''
					this.signCityDis = false
					this.signAreaDis = true
					this.signStreetDis = true
				} else if (value == 2) {
					this.form.signArea = ''
					this.form.signStreet = ''
					this.signAreaDis = false
				} else if (value == 3) {
					this.form.signStreet = ''
					this.signStreetDis = false
				}
				if (!this.form.signProvince) {
					this.signCityDis = true
					this.signAreaDis = true
					this.signStreetDis = true
				}
				if (!this.form.signCity) {
					this.signAreaDis = true
					this.signStreetDis = true
				}
				if (!this.form.signArea) {
					this.signStreetDis = true
				}
			},
			//网点三级变化
			changeArr1(value) {
				if (value == 1) {
					this.form.networkCity = ''
					this.form.networkArea = ''
					this.form.networkStreet = ''
					this.networkCityDis = false
					this.networkAreaDis = true
					this.networkStreetDis = true
				} else if (value == 2) {
					this.form.networkArea = ''
					this.form.networkStreet = ''
					this.networkAreaDis = false
					this.networkStreetDis = true
				} else if (value == 3) {
					this.form.networkStreet = ''
					this.networkStreetDis = false
				}
				if (!this.form.networkProvince) {
					this.networkCityDis = true
					this.networkAreaDis = true
					this.networkStreetDis = true
				}
				if (!this.form.networkCity) {
					this.networkAreaDis = true
					this.networkStreetDis = true
				}
				if (!this.form.networkArea) {
					this.networkStreetDis = true
				}
			},
			//获取三级联动数据
			getProvince() {
				axiosGet('/user/address', {}, (res) => {
					if (res.code == 0) {
						this.signProvinceArr = res.detail
						this.networkProvinceArr = res.detail
					} else {
						this.$message.error(res.detail.result)
					}
				})
			},
			//删除文件之前的函数
			upLoadRemove1(file, fileList) {
				this.fileList1 = fileList;
			},
			upLoadRemove2(file, fileList) {
				this.fileList2 = fileList;
			},
			//文件状态发生变化
			publicUpChange(file, fileList, current) {
				console.log(current)
				const isLt2M = file.size / 1024 < 800;
				if (file.name.split(".")[1] != "jpg" && file.name.split(".")[1] != "png" && file.name.split(".")[1] != "jpeg") {
					this.$message.error('只能上传JPG/PNG/JPEG格式图片');
					if (current == 1) {
						this.fileList1 = fileList.slice(0, -1);
					} else {
						this.fileList2 = fileList.slice(0, -1);
					}
					return
				}
				if (!isLt2M) {
					this.$message.error('上传图片大小不能超过 800kb!,请重新上传');
					if (current == 1) {
						this.fileList1 = fileList.slice(0, -1);
					} else {
						this.fileList2 = fileList.slice(0, -1);
					}
					return
				}
				if (current == 1) {
					this.fileList1 = fileList.slice(-1);
				} else {
					this.fileList2 = fileList.slice(-1);
				}
			},
			upLoadChange1(file, fileList) {
				this.publicUpChange(file, fileList, 1)
			},
			upLoadChange2(file, fileList) {
				this.publicUpChange(file, fileList, 2)
			},
			//点击图片时触发
			upLoadPreview(file) {
				this.imgDialogShow = true
				this.dialogImgUrl = file.url
			},
			closeImg() {
				this.imgDialogShow = false
			},
			changeCompanyTypeArr() {
				if (this.role == 0) {
					this.companyTypeArr = [
						// 						{
						// 							label: '平台管理',
						// 							value: 0
						// 						},
						{
							label: '监管单位',
							value: 10
						},
						{
							label: '使用单位',
							value: 20
						},
						{
							label: '维保单位',
							value: 30
						}
					]
				} else {
					this.companyTypeArr = [{
							label: '使用单位',
							value: 20
						},
						// 						{
						// 							label: '维保单位',
						// 							value: 30
						// 						}
					]
				}
			},
			//上传照片
			uploadImage(imgList) {
				let url = null;
				if (imgList.length > 0) {
					const formData = new FormData();
					formData.append("upfile", imgList[0].raw)
					return this.$axios({
						url: "/utils/upload/",
						method: "post",
						data: formData
					})
				} else {
					return Promise.reject('no image');
				}
			},
			//获取编辑数据
			getComplieList() {
				this.tableLoading = true
				let url = '/user/company/' + this.organizationId + '/'
				axiosGet(url, {}, (res) => {
					this.tableLoading = false
					if (res.code == 0) {
						this.form.companyName = res.detail.name
						let companyType = ''
						if (res.detail.company_type == 100) {
							companyType = 30
						} else if (res.detail.company_type == 300) {
							companyType = 20
						} else if (res.detail.company_type == 400) {
							companyType = 10
						}
						let message = res.detail.record.rec_status ? '更新成功' : '更新失败'
						this.updataType = message + '/' + res.detail.record.msg
						this.lastUpdataTime = res.detail.record.end_time
						this.form.companyType = companyType
						this.form.companyName = res.detail.name
						this.form.comTelephone = res.detail.company_telephone
						this.form.principal = res.detail.person_in_charge
						this.form.principalTele = res.detail.person_in_charge_phone
						this.form.allDayTele = res.detail.telephone
						this.form.unitSite = res.detail.address
						this.form.societyCode = res.detail.unified_code
						this.form.legalPerson = res.detail.legal_person
						this.form.legalPersonTele = res.detail.legal_phone
						this.form.signProvince = res.detail.register_province
						this.form.signCity = res.detail.register_city
						this.form.signArea = res.detail.register_county
						this.form.signStreet = res.detail.register_street
						this.form.networkProvince = res.detail.website.province_num
						this.form.networkCity = res.detail.website.city_num
						this.form.networkArea = res.detail.website.county_num
						this.form.networkStreet = res.detail.website.street_num
						this.form.netDetailSite = res.detail.website.office_address
						this.form.signDetailSite = res.detail.register_address
						this.form.sysCount = res.detail.link_account
						this.form.sysCard = res.detail.link_token
						this.form.title = res.detail.title
						// this.form.unitSite = res.detail.
						if (res.detail.business_lic) {
							this.fileList1 = [{
								name: '',
								url: res.detail.business_lic
							}]
						}
						if (res.detail.lic_pic) {
							this.fileList2 = [{
								name: '',
								url: res.detail.lic_pic
							}]
						}
						if (this.form.signProvince) {
							this.signCityDis = false
						}
						if (this.form.signCity) {
							this.signAreaDis = false
						}
						if (this.form.signArea) {
							this.signStreetDis = false
						}
						if (this.form.networkProvince) {
							this.networkCityDis = false
						}
						if (this.form.networkCity) {
							this.networkAreaDis = false
						}
						if (this.form.networkArea) {
							this.networkStreetDis = false
						}
						if (Object.keys(res.detail.record).length > 0) {
							if (res.detail.record.ret_info) {
								this.recordCon1 = res.detail.record.ret_info
							} else {
								this.recordCon1 = {}
							}
							if (res.detail.record.reg_info) {
								this.recordCon = res.detail.record.reg_info
							} else {
								this.recordCon = {}
							}
						}
					} else {
						this.$message.error(res.detail.result)
					}
				})
			},
			//返回父级路由
			backRouter(value) {
				if (value == 1) {
					let obj = {
						name: '组织管理',
						router: '/MainView/SystemManagement/InstitutionalFramework'
					}
					this.$store.commit('GOTAGROUTER', obj)
				} else {
					this.$emit('closeMessage')
				}
			},
			//保存
			enture(formName, value) {
				this.$refs[formName].validate(async (valid) => {
					if (valid) {
						this.submitBtn = true
						let url = ''
						let method = ''
						let companyType = ''
						if (this.form.companyType == 10) {
							companyType = 400
						} else if (this.form.companyType == 20) {
							companyType = 300
						} else if (this.form.companyType == 30) {
							companyType = 100
						}
						let data = {
							name: this.form.companyName,
							company_type: companyType,
						}
						let upImg1 = ''
						let upImg2 = ''
						if (this.fileList1.length != 0) {
							if (this.fileList1[0].raw) {
								const uploadRes = await this.uploadImage(this.fileList1)
								upImg1 = uploadRes.code === 0 ? uploadRes.detail : ''
							} else {
								upImg1 = this.fileList1[0].url;
							}
						}
						if (this.fileList2.length != 0) {
							if (this.fileList2[0].raw) {
								const uploadRes = await this.uploadImage(this.fileList2)
								upImg2 = uploadRes.code === 0 ? uploadRes.detail : ''
							} else {
								upImg2 = this.fileList2[0].url
							}
						}
						data.business_lic = upImg1
						data.lic_pic = upImg2
						data.company_telephone = this.form.comTelephone //单位电话
						data.telephone = this.form.allDayTele //24小时应急值守电话
						data.person_in_charge = this.form.principal //主要负责人
						data.person_in_charge_phone = this.form.principalTele //负责人电话
						data.legal_person = this.form.legalPerson //法人
						data.legal_phone = this.form.legalPersonTele //法人电话
						data.unified_code = this.form.societyCode //社会统一信用码
						data.link_account = this.form.sysCount
						data.link_token = this.form.sysCard
						data.register_province = this.form.signProvince //注册省
						data.register_city = this.form.signCity //注册市
						data.register_county = this.form.signArea //注册区
						data.register_street = this.form.signStreet //注册街道
						data.register_address = this.form.signDetailSite //详细地址
						data.province_code = this.form.networkProvince //网点省
						data.city_code = this.form.networkCity //网点市
						data.county_code = this.form.networkArea //网点区
						data.street_code = this.form.networkStreet //网点街道
						data.office_address = this.form.netDetailSite
						data.address = this.form.unitSite
						data.title = this.form.title
						if (!this.nowStatus) {
							url = '/user/company/'
							method = 'post'
						} else {
							url = '/user/company/' + this.organizationId + '/'
							method = 'put'
						}
						axiosChange(url, method, data, (res) => {
							this.submitBtn = false
							if (res.code == 0) {
								this.$message({
									type: 'success',
									message: '操作成功'
								})
								if (value == 1) {
									localStorage.RoleManagementFlush = JSON.stringify({
										flush: 1
									})
									this.backRouter()
								} else {
									this.$emit('closeMessage')
								}
							} else {
								this.$message.error(res.detail.result)
							}
						})
					} else {
						console.log('error submit!!');
						return false;
					}
				});
			},
		}
	}
</script>

<style scoped lang='less'>
	.header {
		display: flex;
		justify-content: space-between;
	}

	.content {
		height: 90%;
		width: 100%;
		margin-top: 5px;
	}

	.listName {
		display: flex;
		justify-content: flex-start;
		text-align: left;
		height: 25px;
		align-items: center;

		i {
			width: 3px;
			height: 60%;
			background: #2d8cf0;
			margin: 10px 5px;
			margin-left: 0;
		}

	}

	.el-row {
		margin-left: 0 !important;
		margin-right: 0 !important;
	}
</style>
